<%@ page language="java" pageEncoding="utf-8"%>
<%@page import="com.testingedu.common.QueryResult"%>
<%@page import="com.testingedu.utils.StringUtils"%>
<%@taglib prefix="perm" uri="/tld/permission"%>
<%@page import="com.testingedu.model.TStudyState"%>
<%@page import="com.testingedu.model.TUser"%>
<%@ include file="../common/tiglib.jsp" %>
<%QueryResult queryResult  = (QueryResult)request.getAttribute("queryResult"); %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>

		<title>My JSP 'userList.jsp' starting page</title>

		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<STYLE type="text/css">
.STYLE11 {
	font-size: 15px;
	color: #03515d;
}

.STYLE4 {
	color: #03515d;
	font-size: 12px;
}

A IMG {
	border: 0
}
</STYLE>
		<link rel="stylesheet" type="text/css"
			href="${pageContext.request.contextPath}/css/pingTai/pingTai.css">
		<SCRIPT type="text/javascript">
		var u_delete = '<perm:hasPermission operate="${pageContext.request.contextPath}/admin/studyState/delete" htmlSrc="true" />';
		var u_update = '<perm:hasPermission operate="${pageContext.request.contextPath}/admin/studyState/update" htmlSrc="true" />';
		var u_view = '<perm:hasPermission operate="${pageContext.request.contextPath}/admin/studyState/list" htmlSrc="true" />';
</SCRIPT>
	</head>

	<body>
		<table width="100%" border="0" align="center" cellpadding="0"
			cellspacing="0">
			<tr>
				<td height="3"></td>
			</tr>
			<tr height="20" valign="baseline">
				<td bgcolor="#353c44">
					<img src="${pageContext.request.contextPath}/images/pingTai/tb.gif"
						width="14" height="14" />
					<span class="STYLE1">学习状态查询</span>
				</td>
				<td align="right" bgcolor="#353c44">
					<span class="STYLE1"> </span>
				</td>
			</tr>
			<tr>
				<td height="3" colspan="2"></td>
			</tr>
		</table>
		<form
			action="${pageContext.request.contextPath}/admin/studyState/list"
			method="post" id="_formSearch">
			<table width="100%" border="0" cellpadding="0" cellspacing="1"
				bgcolor="#a8c7ce">

				<tr bgcolor="#FFFFFF" class="STYLE19">
					<td align="center" width="15%">
						学生姓名:
						<input type="text" name="userName" size="50" id="_name">
					</td>
				</tr>
				<tr bgcolor="#FFFFFF" class="STYLE19">
					<td colspan="4" align="center">
						<input type="button" value="提交" class="button2" onclick="validateWhere();">
						&nbsp;&nbsp;
						<input type="reset" value="重置" class="button2">&nbsp;&nbsp;
						<perm:hasPermission
							operate="${pageContext.request.contextPath}/admin/studyState/add"
							htmlSrc="<input type='button' value='添加学习状态' onclick='add()' class='button4'/>" />
					</td>

				</tr>

			</table>
		</form>
		<table width="100%" border="0" align="center" cellpadding="0"
			cellspacing="0">
			<tr>
				<td height="3"></td>
			</tr>
			<tr height="20" valign="baseline">
				<td bgcolor="#353c44">
					<img src="${pageContext.request.contextPath}/images/pingTai/tb.gif"
						width="14" height="14" />
					<span class="STYLE1">学习状态列表</span>
				</td>
				<td align="right" bgcolor="#353c44">
					<span class="STYLE1"> </span>
				</td>
			</tr>
			<tr>
				<td height="3" colspan="2"></td>
			</tr>
		</table>

		<table width="100%" border="0" cellpadding="0" cellspacing="1"
			bgcolor="#a8c7ce" onmouseover="changeto()" onmouseout="changeback()"
			onclick="clickto()">
			<tr id="orderTr" align="center" class="STYLE10" height="20"
				bgcolor="d3eaef">
				<td width="5%">
					编号
				</td>
				<td width="10%">
					学生姓名
				</td>
				<td width="20%">
					状态
				</td>
				<td width="10%">
					添加日期
				</td>
				<td width="20%">
					基本操作
				</td>
			</tr>
			<%
					for(int i = 0 ; i < queryResult.getResultList().size(); i++) {
						TStudyState tStudyState = (TStudyState)queryResult.getResultList().get(i);
					%>
				<tr align="center" bgcolor="#FFFFFF" class="STYLE19">
					<td>
						<%=(i+1) %>
					</td>
					<td>
						<%=tStudyState.gettUser().getName()%>
					</td>
					<td>
						<%=StringUtils.substring(tStudyState.getState(),30) %>
					</td>
					<td>
						<%=tStudyState.getAddTime() %>
					</td>
					<td>
						<SCRIPT type="text/javascript">
						if(u_view == 'true') {
							document.write('<a href="${pageContext.request.contextPath}/admin/studyState/list?id=<%=tStudyState.getId()%>&url=info"><font color="blue">详细信息</font></a>');
						}
						if(u_update == 'true') {
							document.write('&nbsp;|&nbsp;<a href="${pageContext.request.contextPath}/admin/studyState/update?id=<%=tStudyState.getId()%>&url=update"><font color="blue">修改信息</font></a>');
						}
						if(u_delete == 'true') {
							document.write('&nbsp;|&nbsp;<a href="${pageContext.request.contextPath}/admin/studyState/delete?id=<%=tStudyState.getId()%>"><font color="red">删除</font></a>');
						}
					</SCRIPT>
					</td>
				</tr>
				<%} %>
		</table>
		<table width="100%" border="0" cellspacing="0" cellpadding="0"
			align="right">
			<tr>
				<td class="STYLE4" valign="middle">
					&nbsp;&nbsp;共有
					<%=queryResult.getAllCount() %>
					条记录，当前第
					<%=queryResult.getCurrentPage() %>
					/
					<%=queryResult.getAllPage() %>
					页
				</td>
				<td>
					<table border="0" align="right" cellpadding="0" cellspacing="0">
						<tr>
							<td width="40" height="20" valign="middle">
								<a href="javascript:pageGo(1)"><img
										src="${pageContext.request.contextPath}/images/page/first.gif" />
								</a>
							</td>
							<%if(queryResult.getCurrentPage() > 1) {%>
								<td width="40" height="20" valign="middle">
									<a
										href="javascript:pageGo(<%=(queryResult.getCurrentPage() - 1) %>)"><img
											src="${pageContext.request.contextPath}/images/page/back.gif"
											width="43" height="15" /> </a>
								</td>
							<%} %>
							<%if(queryResult.getCurrentPage() < queryResult.getAllPage()) {%>
								<td width="45" height="20" valign="middle">
									<a
										href="javascript:pageGo(<%=(queryResult.getCurrentPage() + 1) %>)"><img
											src="${pageContext.request.contextPath}/images/page/next.gif"
											width="43" height="15" /> </a>
								</td>
							<%} %>
							<td width="40" height="20" valign="middle">
								<a
									href="javascript:pageGo(<%=(queryResult.getAllPage()) %>)"><img
										src="${pageContext.request.contextPath}/images/page/last.gif"
										width="37" height="15" /> </a>
							</td>
							<td width="140" height="20" valign="bottom">
								<span class="STYLE11">&nbsp;转到第<input type="text"
										size="4" name="currentPage" id="goToPage"
										style="height: 20px; width: 20px; border: 1px solid #999999;text-align: center;" />页
									<button
										onclick="pageGo(document.getElementById('goToPage').value)">
										GO
									</button> </span>
							</td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
	</body>
	<script type="text/javascript">
		function add() {
			var userId = <%=request.getAttribute("userId")%>;
			if(userId == 0) {
				alert('请选择具体学员再添加其学习状态！');
			} else {
				window.location.href = "${pageContext.request.contextPath}/admin/studyState/add?url=jsp&userId="+userId;
			}
		}
		function pageGo(goToPage) {
			if(<%= queryResult.getCurrentPage()%> == goToPage) {
				return;
			}
			if(<%= queryResult.getAllPage()%> < goToPage) {
				return;
			}
			window.location.href = "${pageContext.request.contextPath}/admin/studyState/list?_currentPage="+goToPage;
		}
		function validateWhere() {
			var name = $('#_name').val();
			if(name.length > 20){
				alert('学生姓名查询条件过长，只能在20个字符之内！');
				return;
			}
			$('#_formSearch').submit();
		}
	</script>
</html>